<div id="divListGroup">
    <?php echo View::factory('admin/common/breadcrumbs')->set('breadcrumbs', $breadcrumbs)->render(); ?>

    <div class="page-content">
        <div class="page-header">
            <h1>
                List Group     
            </h1>
        </div>
        <?php echo View::factory('admin/common/messege')->render(); ?>
        <form id="frmlistgroup" onsubmit="return false;">
            <div class="row" style="height: 60px;">
                <div class="col-sm-9">
                    <div id="sample-table-2_length" class="dataTables_length">
                        <div class="col-xs-12 col-sm-6">
                            <div class="input-group">
                                <input type="text" placeholder="Enter a name for search" class="form-control search-query" id="textsearch" name="textsearch"  >
                                <span class="input-group-btn">
                                    <button class="btn btn-purple btn-sm" id="cmdSearch" type="button">
                                        Search
                                        <i style="line-height:normal;" class="icon-search icon-on-right bigger-110"></i>
                                    </button>
                                </span>
                            </div>
                        </div>

                    </div>
                </div>

            </div>
            
            <input type="hidden" id="page" name="page" value="1" />
            <div class="row">
                <div class="col-xs-12">
                    <!-- PAGE CONTENT BEGINS -->
                    <div class="row-fluid">
                        <div class="span12">
                            <div class="widget-box">
                                <table id="list-table-3" class="table table-striped table-bordered table-hover">
                                    <thead>
                                        <tr>
                                            <th style="text-align: center;">Id</th>
                                            <th style="text-align: center;">Name</th>
                                          
                                            <th style="text-align: center;">Description</th>
                                            <th style="text-align: center;">Action</th>
        <!--                                    <th style="text-align: center;">Image</th>-->

                                        </tr>
                                    </thead>
                                    <tbody data-bind="foreach:{data : groups , as: 'group'} ">
                                        <?php
                                        if (empty($en_group)) {
                                            ?>
                                        <td style="text-align: center;"  colspan ="5">
                                            <h2>This doesn't have any group permission</h2>
                                        </td>
                                        <?php
                                    } else {
                                        foreach ($en_group as $item) {
                                            $a_group = $item->get_data();
                                            ?>
                                            <tr>
                                                <td style="text-align: center;">
                                                    <b>
                                                        <span data-bind="text:group.id"><?php echo $a_group->getId(); ?></span>
                                                    </b>&nbsp;
                                                </td>
                                                <td style="text-align: center;">
                                                    <span data-bind="text:group.name"><?php echo $a_group->getName(); ?></span>

                                                </td>
                                                
                                                <td style="text-align: center;">
                                                    <span data-bind="text:group.description"><?php echo $a_group->getDescription() ?></span>
                                                </td>
                                                <td style="text-align: center;">
                                                    <?php
                                                    if (isset($_REQUEST['page'])) {
                                                        $page = '&page=' . $_REQUEST['page'];
                                                    } else {
                                                        $page = '';
                                                    }
                                                    ?>
                                                    <?php
                                                    if (Controller_Helper_Authentication::check_permission_admin('admin', 'group', 'edit')) {
                                                        ?>
                                                    <a class="btn btn-xs btn-info classEdit" href="<?= URL::base() . 'admin/group/edit?id=' . $a_group->getId() . $page ?>&redirect=<?= urlencode(Controller_Helper_Url::full_url()) ?>" ><i class="icon-edit bigger-120"></i></a>
                                                        &nbsp;
                                                    <?php } ?>

                                                    <?php
                                                    if (Controller_Helper_Authentication::check_permission_admin('admin', 'group', 'deleted')) {
                                                        ?>
                                                        <a href="#cmdDelete" class="btn btn-xs btn-danger classDelete" itemid="<?= $a_group->getId() ?>" data-toggle="modal"><i class="icon-trash bigger-120"></i></a>
                                                    <?php } ?>
                                                   
                                                </td>
                                            </tr>
                                            <?php
                                        }
                                    }
                                    ?>
                                    </tbody>
                                </table>
                                <div class="row">
                                    <div class="col-sm-6">
                                        <div class="dataTables_info" id="sample-table-2_info"></div>

                                    </div>
                                    <div class="col-sm-6" data-bind="html:pagination" > <!-- data-bind="html:pagination" --> 
                                        <?= $pagination ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- PAGE CONTENT ENDS -->
                </div><!-- /.col -->
            </div><!-- /.row -->
        </form>
        <div id="modal-delete" class="modal fade" tabindex="-1">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header no-padding">
                        <div class="table-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                <span class="white">&times;</span>
                            </button>
                            Delete
                        </div>
                    </div>

                    <div class="modal-body no-padding">
                        <div style="padding: 20px;">
                            Are you sure delete this group?
                        </div>
                    </div>

                    <div class="modal-footer no-margin-top">
                        <button type="button" class="btn btn-sm pull-right" data-dismiss="modal">
                            <i class="icon-remove"></i>
                            Close
                        </button>
                        <div class="pull-right">
                            &nbsp;
                        </div>
                        <button type="button" class="btn btn-sm btn-danger pull-right" id="cmdDelete">
                            <i class="icon-remove"></i>
                            Delete
                        </button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- PAGE CONTENT ENDS -->
    </div>
</div>

<script>
    var _group_list = group_list.CreateObject({
        id: '_group_list',
        full_url: '<?= Controller_Helper_Url::full_url() ?>'
    });
</script>
